<template>
  <div class="stock-query">
    <div>
      <label>
        <input type="radio" name="goods" checked>
        <div>
          <div>全部产品</div>
          <div>5823</div>
        </div>
      </label>
      <label>
        <input type="radio" name="goods">
        <div>
          <div>内衣产品</div>
          <div>1000</div>
        </div>
      </label>
    </div>
    <div class="stock-query__content">
      <div class="stock-query__content--input">
        <span>产品搜索</span>
        <n-input type="text" placeholder="请输入产品款号" />
        <button>重置</button>
        <div>
          <label>
            <input type="radio" name="isDefault" checked />
            <div>默认显示</div>
          </label>
          <label>
            <input type="radio" name="isDefault" />
            <div>仅显示库存</div>
          </label>
        </div>
      </div>
      <n-data-table bordered :columns="columns" :data="list" striped :scroll-x="1800" :max-height="'39.5vh'" />
    </div>
    <div>
      <n-pagination v-model:page="page" :page-count="100" :page-slot="7">
        <template #prev>
          上一页
        </template>
        <template #next>
          下一页
        </template>
        <template #suffix>
          <div class="pagination__jump-page">
            到<input type="number">页
            <button>确定</button>
            <span>10 条 / 页</span>
          </div>
        </template>
      </n-pagination>
    </div>
  </div>
</template>

<script setup>
import { reactive, ref, h } from 'vue';
import goodsRow from "../@fragment/goods-row.vue";
const page = ref(1);
const columns = [
  {
    title: '名称/款号', key: 'name', render () {
      return h(goodsRow, { name: true })
    }
  },
  { title: '产品库存', key: 'age' },
  { title: '产品类型', key: 'address' },
  {
    title: '操作',
    fixed: 'right',
    width: 200,
    render () {
      return h(goodsRow, {
        details: '查看详情', onClick () { }
      })
    }
  }
];
const list = reactive([{
  key: 0,
  name: 'John Brown',
  age: 32,
  address: 'New York No. 1 Lake Park'
}
])
</script>

<style lang="less" scoped>
.stock-query {
  display: flex;
  flex-direction: column;
  height: 100%;

  * {
    line-height: 1;
  }

  > div:first-child {
    display: flex;
    padding: 20px 0 19px 20px;
    box-sizing: border-box;
    overflow-x: scroll;

    > label {
      flex-shrink: 0;
      margin-right: 18px;

      input {
        display: block;
        width: 0;
        height: 0;
        opacity: 0;
      }

      input + div {
        width: 200px;
        height: 104px;
        background: #ffffff;
        border: 1px solid #e5e5e5;
        border-radius: 5px;

        > div {
          text-align: center;
          font-size: 26px;
          color: #4a5060;
        }

        > div:first-child {
          margin: 19px 0;
        }

        > div:last-child {
          font-size: 30px;
          font-weight: bold;
          color: #2e323d;
        }
      }

      input:checked + div {
        background: #e5f2ff;
        border: 2px solid #1981f4;
        box-shadow: 0px 0px 10px 0px rgba(1, 1, 1, 0.3);

        > div {
          color: #2c8cf0;
        }
      }
    }
  }

  &__content {
    flex: 1;
    margin: 0 30px;
    padding-top: 20px;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    &--input {
      display: grid;
      grid-template-columns: auto 380px auto auto;
      align-items: center;
      justify-content: start;
      margin-bottom: 28px;

      > span {
        margin-right: 19px;
        font-size: 26px;
        color: #2e323d;
      }

      > button {
        margin-left: 18px;
        width: 114px;
        height: 60px;
        font-size: 26px;
        background: #f8f8f8;
        border: 1px solid #aaaaaa;
        border-radius: 5px;
        color: #2e323d;
      }

      > div:last-child {
        display: flex;
        padding-left: 78px;

        > label {
          > input {
            display: block;
            width: 0;
            height: 0;
            opacity: 0;
          }

          > input + div {
            width: 148px;
            height: 60px;
            font-size: 26px;
            line-height: 60px;
            background: #f8f8f8;
            border: 1px solid #e5e5e5;
            border-radius: 5px 0px 0px 5px;
            text-align: center;
          }

          > input:checked + div {
            background: #e5f2ff;
            border: 1px solid #1981f4;
            color: #1981f4;
          }
        }

        > label:last-child {
          > input + div {
            border-radius: 0px 5px 5px 0px;
          }
        }
      }
    }
    /deep/ td {
      vertical-align: middle;
    }
  }

  > div:last-child {
    display: flex;
    align-items: center;
    padding: 0 30px;
    height: 128px;
    box-sizing: border-box;
    box-shadow: 0px 1px 10px 0px rgba(0, 0, 0, 0.2);
    .pagination__jump-page {
      font-size: 26px;
      color: #4a5060;
      margin: 0 18px;

      input {
        margin: 0 15px;
        width: 64px;
        height: 42px;
        text-align: center;
        background: #f8f8f8;
        border: 1px solid #e5e5e5;
        border-radius: 5px;
      }

      button {
        margin: 0 30px;
        width: 88px;
        height: 44px;
        color: #fdfdfd;
        background: #2c8cf0;
        border-radius: 5px;
      }
    }
  }
}
</style>